<template>
  <div class="login">
<div class="login_box">

<div class="img_box">
    <img src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png">

</div>

<el-form :model="from" :rules="rules"  label-width="0px"
class="login_index" ref="loginfrom">
<h2 style="text-align: center; color: #d2cea6; font-size: 30px;">登入账号</h2>
  <el-form-item prop="user">
    <el-input placeholder="请输入用户名"  prefix-icon="el-icon-user" v-model="from.user" ></el-input>
  </el-form-item>
  <el-form-item prop="pass">
    <el-input placeholder="请输入密码" v-model="from.pass" show-password prefix-icon="el-icon-lock">
    </el-input>
  </el-form-item>
  <div>
    <span class="want1">
    记住<input type="checkbox"></span>
    <span class="want">忘记密码？</span>
  </div>
  <el-form-item class="btu">
    <el-button type="primary" plain
    @click="open1">登录</el-button>
    <el-button type="info" @click="loginfrom" :plain="true">注册</el-button>
  </el-form-item>
  </el-form>
</div>
  </div>
</template>
<script>

export default {
  name: 'LoginTest',
  data () {
    return {
      from: {
        user: '3233597374',
        pass: '123456'
      },
      rules: {
        user: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          { min: 8, max: 20, message: '长度在 8 到 20 个字符，只允许输入数字', trigger: 'blur' }
        ],
        pass: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { min: 6, max: 15, message: '长度在 6 到 15 个字符，包括大写、小写及下划线', trigger: 'blur' }
        ]
      }
    }
  },

  methods: {
    loginfrom () {
    //   this.$refs.loginfrom.resetFields(),
      this.$message.warning('即将跳转至注册界面！')
      setTimeout(() => {
        this.$router.push('/regist')
      }, 3000)
    },
    open1 () {
      this.$refs.loginfrom.validate(valid => {
        if (!valid && (!this.user && !this.pass)) {
          this.$message.error('登录失败')
        } else {
          this.$message({
            title: '成功',
            message: '登录成功！',
            type: 'success'
          })
          setTimeout(() => {
            this.$router.push('/main')
          }, 2000)
        }
      })
    },
    components: {},
    computed: {}
  }
}
</script>
<style lang="less" scoped>
.want:hover{
  opacity: 0.8;
}
.want{
  color: rgb(54, 112, 198);
  font-family:宋体;
 position: relative;
 left: 380px;
}
.want1{
  font-family:宋体;
}
.login{
    background-color: rgb(234, 229, 205);
    border-radius: 12px;
    height: 100%;

}
.login_box{
    width: 550px;
    height: 400px;
    background-color:#faf6f6;
    border-radius: 12px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);

    .img_box{
        height: 100px;
        width: 100px;
        border: 1px solid #eee;
        border-radius: 50%;
        position: relative;
            left: 50%;
            padding: 10px;
            box-shadow: 0 0 0 10px #ddd;
            transform: translate(-50%,-50%);
            background-color: #ccc;
        img{
            width: 100%;
            height: 100%;
            border-radius: 50%;
            position: relative;
            margin: auto;
            background-color: antiquewhite;
        }
    }
}
.login_index{
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    transform: translate(0,-15%);

}
.btu{
    display: flex;
    justify-content: flex-end;
    position: relative;
    top: 30px;
}
.el-button{
border-radius: 20px;
}
.el-menu{
    border-right: none;
}
</style>
